package com.zookeeper.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class OrderApiController {

    @Autowired
    RestTemplate restTemplate;
    @Autowired
    private DiscoveryClient discoveryClient;


    @RequestMapping("/getOrder")
    public String getOrder(){
        String url = "http://app-zookeeper-member/getMember";
        String result = restTemplate.getForObject(url, String.class);
        return result;
    }

    @RequestMapping("/getDiscoveryClient")
    public List getDiscoveryClient(){
        List<ServiceInstance> instances = discoveryClient.getInstances("app-zookeeper-member");
        return instances;
    }

}
